<template>
  <div class="wrap">
    <header>
      <h3>订单查询</h3>
    </header>
    <main>
      <div class="dingdan1">
        <div class="chose">
          <label>订单类型:</label>
          <input type="text" placeholder="资讯名称" />
          <div class="ipt">
            <label>搜索:</label>
            <input type="text" v-model="val" />
            <button @click="search">查询</button>
          </div>
        </div>
        <div class="list">
          <el-table :data="tableData" style="width: 100%">
            <el-table-column label="序号" prop="id" width="180"></el-table-column>
            <el-table-column label="文章标题" prop="title" width="180"></el-table-column>
            <el-table-column label="创建人" prop="name" width="180"></el-table-column>
            <el-table-column label="创建日期" prop="date" width="180"></el-table-column>
            <el-table-column label="状态" prop="staus" width="180"></el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button size="mini" type="danger">编辑</el-button>
                <el-button size="mini" type="danger" @click="del(scope.row.id)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </main>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      tableData: [],
      value1: "",
      options1: [
        {
          value: "选项1",
          label: "二手房出租"
        },
        {
          value: "选项2",
          label: "有房出租"
        },
        {
          value: "选项3",
          label: "我想买个房"
        },
        {
          value: "选项4",
          label: "我想租个房"
        }
      ],
      val: ""
    };
  },
  created() {
    this.getList();
  },
  methods: {
    async getList() {
      const res = await axios.post("/api/search", { val: this.val });
      this.tableData = res.data.data;
      // axios({
      //   url: "/api/getList",
      //   method: "post"
      // }).then(res => {
      //   console.log(res);
      //   this.tableData = res.data.data;
      // });
    },
    del(id) {
      axios({
        url: "/api/delList",
        method: "post",
        data: { id }
      }).then(res => {
        console.log(res);
        this.getList();
      });
    },

    search() {
      this.getList();
    }
  }
};
</script>

<style lang='scss' scoped>
.wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  // border: 1px solid #999;
}
header {
  height: 30px;
  line-height: 30px;
  color: #999;
}
main {
  .dingdan1 {
    .chose {
      display: flex;
      align-items: center;
      margin-top: 10px;
      label {
        font-size: 17px;
        color: #333;
        margin-right: 5px;
      }
      .ipt {
        display: flex;
        align-items: center;
        margin-left: 20px;
        input {
          border-collapse: collapse;
          width: 160px;
          height: 37px;
          border-radius: 3px;
          background: #fff;
        }
        button {
          width: 80px;
          height: 37px;
          border: none;
          background: #999;
          font-size: 16px;
          border-radius: 3px;
          margin-left: 8px;
        }
      }
    }
    .list {
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      margin-top: 15px;
      tr {
        border: 1px solid #ccc;
        line-height: 20px;
        text-align: center;
        align-items: center;
        th {
          line-height: 40px;
          padding: 0 85px;
        }
        td {
          line-height: 35px;
          padding: 0 15px;
        }
      }
    }
  }
}
</style>